package com.autumn.xa.a.demo.data;


import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ClassName: GetMessage
 *
 * @Description:
 * @Author: wangqiuyang
 * @Date: 2022/4/22 3:01 下午
 * History:
 * <author>          <time>          <version>          <desc>
 * wangqiuyang    2022/4/22 3:01 下午   @Version 1.0        描述
 */
public class GetMessage {

    private static final String tokenStr =  "bearer 073850FA4F62477788EF7A29E3033F272022042610460433A3E66C";

    private static List<DATA> getData() {
        List<DATA> dataList = new ArrayList<>();
        Collections.addAll(dataList ,
                new DATA("91310000MA1H3A0F00","上海叁零肆零科技有限公司"),
                new DATA("9131011713214185XQ","上海埃科燃气测控设备有限公司"),
                new DATA("9131011332320426X2","上海新奥新能源技术有限公司"),
                new DATA("91310000740282787T","上海波汇科技有限公司"),
                new DATA("91310000586778185R","上海真兰仪表科技股份有限公司"),
                new DATA("91310000682266227Y","上海翼捷工业安全设备股份有限公司"),
                new DATA("913713007677792085","临沂宏盛铸业有限公司"),
                new DATA("91331082MA2DW6UA6L","临海伟星新型建材有限公司"),
                new DATA("91330000610003372E","公元股份有限公司"),
                new DATA("91110106750116010T","北京京燃凌云燃气设备有限公司"),
                new DATA("911101151011765741","北京市阀门总厂股份有限公司"),
                new DATA("913201175555470777","南京柔科航空设备科技有限公司"),
                new DATA("9132010455550179X0","南京益美沃电子科技有限公司"),
                new DATA("914403006188883633","南塑建材塑胶制品（深圳）有限公司"),
                new DATA("91110108560403924X","博康智能信息技术有限公司"),
                new DATA("91510122MA61WRL35N","四川希尔得科技有限公司"),
                new DATA("91371000MA3PEJA82P","埃尔法（山东）仪器有限公司"),
                new DATA("91330327254674005K","天信仪表集团有限公司"),
                new DATA("91120118MA05KM81XX","天津九衢大数据科技有限公司"),
                new DATA("911202233005959581","天津友发钢管集团销售有限公司"),
                new DATA("9112011660055375X2","天津费加罗电子有限公司"),
                new DATA("913710006768284060","威海市乐家电子科技有限公司"),
                new DATA("913302266102641340","宁波华成阀门有限公司"),
                new DATA("91330281144654281Y","宁波宇华实业股份有限公司"),
                new DATA("91330205720400782T","宁波杰克龙精工有限公司"),
                new DATA("91330324704353306C","宣达实业集团有限公司"),
                new DATA("91131000728822779M","廊坊新奥智能科技有限公司"),
                new DATA("915101007092953446","成都安可信电子股份有限公司"),
                new DATA("9151010068181149XN","成都川力智能流体设备股份有限公司"),
                new DATA("91510112095263865Q","成都特恩达燃气设备有限公司"),
                new DATA("91510108746444230K","成都鑫豪斯电子探测技术有限公司"),
                new DATA("913202137624224450","无锡华贝钢管制造有限公司"),
                new DATA("91410581660948585B","林州凤宝管业有限公司"),
                new DATA("914101007067858314","汉威科技集团股份有限公司"),
                new DATA("913212007306957640","江苏新高波纹管有限公司"),
                new DATA("91320509251324851W","江苏达胜热缩材料有限公司"),
                new DATA("911309006013103039","沧州明珠塑料股份有限公司"),
                new DATA("91130930592482970C","河北一塑管道制造有限责任公司"),
                new DATA("91130900109713274N","河北凯瑞管件制造股份有限公司"),
                new DATA("91130930601043022T","河北广浩管件有限公司"),
                new DATA("911311216011586394","河北永良燃气设备有限公司"),
                new DATA("91130925684303458U","河北汇中管道装备有限公司"),
                new DATA("9113108234766421XJ","河北秦汉电子科技有限公司"),
                new DATA("913701006722863472","济南本安科技发展有限公司"),
                new DATA("91370113689804622W","济南火哨安全科技有限公司"),
                new DATA("91330201340495644X","浙江世亚燃气阀门有限公司"),
                new DATA("91330000719525019T","浙江伟星新型建材股份有限公司"),
                new DATA("91330200144841431J","浙江圣字管业股份有限公司"),
                new DATA("913302810847600658","浙江庆发管业科技有限公司"),
                new DATA("91330281728102202G","浙江新大塑料管件有限公司"),
                new DATA("91330000609671736A","浙江春晖智能控制股份有限公司"),
                new DATA("91330301733816242P","浙江正康实业股份有限公司"),
                new DATA("91330681MA2D6BC441","浙江浩海管业有限公司"),
                new DATA("91331021MA2AL79K4P","浙江班尼戈智慧管网股份有限公司"),
                new DATA("91330327145778462F","浙江苍南仪表集团股份有限公司"),
                new DATA("91330681704512055D","浙江迪艾智控科技股份有限公司"),
                new DATA("913300001469757672","浙江金洲管道科技股份有限公司"),
                new DATA("91420881615408651X","湖北钟格塑料管有限公司"),
                new DATA("91430111087603401Q","湖南天联城市数控有限公司"),
                new DATA("91370700765761274A","潍坊中石科技有限公司"),
                new DATA("91320400137517852H","特瑞斯能源装备股份有限公司"),
                new DATA("9113022978982046XL","玉田县北环玛钢有限公司"),
                new DATA("91370124613225093N","玫德集团有限公司"),
                new DATA("91320982140659739Q","盐城市大丰燃气设备有限公司"),
                new DATA("91310000580584777H","罗美特（上海）自动化仪表股份有限公司"),
                new DATA("91320000714091899R","航天晨光股份有限公司"),
                new DATA("91320411746804750X","良正阀门有限公司"),
                new DATA("913402007981108226","芜湖泰和管业股份有限公司"),
                new DATA("9137060016504348XP","莱钢集团烟台钢管有限公司"),
                new DATA("91430400722565521G","衡阳科盈钢管有限公司"),
                new DATA("914101006807820337","郑州万达重工股份有限公司"),
                new DATA("91500112622003214R","重庆胜山燃气设备有限公司"),
                new DATA("91441200MA511T466D","钜溢（肇庆）钢管制造有限公司"),
                new DATA("91370200743990287F","青岛优派普环保科技股份有限公司"),
                new DATA("912103006961835104","鞍山天汇科技有限公司")
                );
        return dataList;
    }

    /**
     * 127-司法拍卖 26行
     */
    private static void get1(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();

        for (DATA datum : data) {

            String url = "https://sandbox.hscloud.cn/data_check/v1/business/judicialSale?" +
                    "page_no=1&branch_credit_code=" + datum.getCode() +
                    "&enterprise_name=" + datum.getName();

            Map<String,String> header = new HashMap<>();
            header.put("Authorization","Bearer 923D89CC948E40D58F71B1474B477AD32022042215392233A3E66C");
            String result = HttpRequest.get(url).addHeaders(header).execute().body();

            System.out.println(result);
        }
    }

    /**
     * 行政处罚 18行 第一个
     * https://sandbox.hscloud.cn/data_check/v1/business/punishmentInfo?page_no=1&branch_credit_code=9111000071093465XC&enterprise_name=中国邮政储蓄银行股份有限公司
     * @param args
     */
    private static void get2(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/data_check/v1/business/punishmentInfo?" +
                    "&enterprise_name=" + datum.getName();


            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);
            if (resultJSON.get("data") != null) {
                success ++;
                System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
                successList.add(datum);
            }

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.toString());
        }
        
        
    }

    /**
     *  17行
     * https://sandbox.hscloud.cn/rdm/v1/rdm-cloud-gildata/gildata_comgrad/query?credit_code=913300002539329145&company_name=恒生电子股份有限公司&company_code=1504
     * @param args
     */
    private static void get3(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/rdm/v1/rdm-cloud-gildata/gildata_comgrad/query?" +
                    "credit_code=" + datum.getCode() +
                    "&company_name=" + datum.getName() +
                    "&company_code=1504" ;


            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);
//            if (resultJSON.get("data") != null) {
//                success ++;
//                System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
//                successList.add(datum);
//            }

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.toString());
        }


    }

    /**
     * 资产负债表 14行
     * https://sandbox.hscloud.cn/rdm/v1/rdm-cloud-gildata/gildata_financ_balance/query?credit_code=91530325784625681H&enterprise_name=云南东恒经贸集团有限公司
     * @param args
     */
    private static void get4(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/rdm/v1/rdm-cloud-gildata/gildata_financ_balance/query?" +
                    "credit_code=" + datum.getCode() +
                    "&enterprise_name=" + datum.getName();


            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);

            List<JSONObject> dataList = (List<JSONObject>)resultJSON.get("data");
            if (dataList.size() != 0) {
                success ++;
                System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
                successList.add(datum);
            }

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.toString());
        }


    }


    /**
     *  6行 /rdm-cloud-gildata/gildata_financ_balance/query
     * https://sandbox.hscloud.cn/rdm/v1/rdm-cloud-gildata/gildata_financ_net_income/query?credit_code=9111000071093465XC&enterprise_name=中国邮政储蓄银行股份有限公司
     * @param args
     */
    private static void get5(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/rdm/v1/rdm-cloud-gildata/gildata_financ_net_income/query?" +
                    "credit_code=" + datum.getCode() +
                    "&enterprise_name=" + datum.getName() ;


            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);
            if (resultJSON.get("data") == null) {
                continue;
            }
            List<JSONObject> dataList = (List<JSONObject>)resultJSON.get("data");
            if (dataList.size() != 0) {
                success ++;
                System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
                successList.add(datum);
            }

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.toString());
        }


    }

    /**
     *  6行
     * https://sandbox.hscloud.cn/data_check/v1/business/dishonest?page_no=1&branch_credit_code=915301297194079607&enterprise_name=云南天时房地产开发经营有限公司
     * @param args
     */
    private static void get6(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/data_check/v1/business/dishonest?page_no=1" +
                    "&enterprise_name=" + datum.getName();

            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

//            JSONObject resultJSON = JSONObject.parseObject(result);
//            if (resultJSON.get("data") == null) {
//                continue;
//            }
//            List<JSONObject> dataList = (List<JSONObject>)resultJSON.get("data");
//            if (dataList.size() != 0) {
//                success ++;
//                System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
//                successList.add(datum);
//            }

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.toString());
        }


    }


    /**
     *  6行
     * https://sandbox.hscloud.cn/data_check/v1/business/zhixinginfo?branch_credit_code=915301297194079607&enterprise_name=云南天时房地产开发经营有限公司
     * @param args
     */
    private static void get7(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/data_check/v1/business/zhixinginfo?" +
                    "&enterprise_name=" + datum.getName();

            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);
            if (resultJSON.get("data") == null) {
                continue;
            }

            success ++;
            System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
            successList.add(datum);

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.toString());
        }


    }


    /**
     *  6行
     * https://sandbox.hscloud.cn/data_check/v1/business/taxCredit?page_no=1&enterprise_name=上海真兰仪表科技股份有限公司
     * @param args
     */
    private static void get8(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/data_check/v1/business/taxCredit?" +
                    "page_no=1&enterprise_name=" + datum.getName();

            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);
            if (resultJSON.get("data") == null) {
                continue;
            }
            JSONObject dataList = (JSONObject)resultJSON.get("data");
            if (dataList != null) {
                success ++;
                System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
                successList.add(datum);
            }

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.getName());
        }


    }

    /**
     * 动产抵押
     * https://sandbox.hscloud.cn/data_check/v1/business/mortgageInfo?page_num=1&branch_credit_code=91530325784625681H&enterprise_name=云南东恒经贸集团有限公司
     * @param args
     */
    private static void get9(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/data_check/v1/business/mortgageInfo?page_num=1" +
                    "&enterprise_name=" + datum.getName();


            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);
            if (resultJSON.get("data") == null) {
                continue;
            }
            JSONObject dataList = (JSONObject)resultJSON.get("data");
            if (dataList != null) {
                success ++;
                System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
                successList.add(datum);
            }

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.getName());
        }


    }

    /**
     * 新三板
     * https://sandbox.hscloud.cn/rdm/v1/rdm-cloud-gildata/gildata_nq_liabilities/query?enterprise_name=浙江春晖智能控制股份有限公司
     * @param args
     */
    private static void get10(){
        List<DATA> data = getData();

        int success = 0;
        int total = data.size();
        List<DATA> successList = new ArrayList<>();
        List<DATA> failList = new ArrayList<>();

        for (DATA datum : data) {
            String url = "https://sandbox.hscloud.cn/rdm/v1/rdm-cloud-gildata/gildata_nq_liabilities/query?" +
                    "enterprise_name=" + datum.getName() +
                    "&begin_date=20180101" ;



            Map<String,String> header = new HashMap<>();
            header.put("Authorization",tokenStr);
            System.out.println(url);
            String result = HttpRequest.get(url).addHeaders(header).execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);
            List<JSONObject> data1 = (List<JSONObject>)resultJSON.get("data");
            if (data1.size() == 0) {
                continue;
            }
            success ++;
            System.out.println("=========================== 这些企业查到了  " + datum.getName() + "    code:    " + datum.getCode());
            successList.add(datum);

        }


        System.out.println("结果 ： 查到了   " + success + "   个");
        System.out.println("结果 ： ======================= success list");
        for (DATA data1 : successList) {
            System.out.println(data1.getName());
        }


    }


    private static void post1() {

        List<DATA> datas = getData();

        int success = 0;
        int fail = 0;

        List<String> successList = new ArrayList<>();
        List<String> failList = new ArrayList<>();


        for (DATA data : datas) {
            String url = "http://api.qixin.com/APIService/qc/getANList?" +
                    "name=" + data.getName() +
                    "&appkey=df497b29-1d10-4aac-b922-9fa402750751" +
                    "&secret_key=d10a26d1-34db-4b91-8dd0-2df486a462bc" ;


            System.out.println(url);
            String result = HttpRequest.get(url)/*.addHeaders(header)*/.execute().body();
            System.out.println(result);

            JSONObject resultJSON = JSONObject.parseObject(result);
            String code = (String)resultJSON.get("status");
            if ("200".equals(code)) {
                success ++;
                successList.add(data.getName());
            } else if ("201".equals(code)){
                fail ++;
                failList.add(data.getName());
            } else {
                fail ++;
                failList.add(data.getName());
            }
        }

        System.out.println("successful total" + success);
        System.out.println("fail total" + fail);

        System.out.println("========== 成功的企业列表");

        for (String success1 : successList) {
            System.out.println(success1);
        }

        System.out.println("========== 失败的企业列表");

        for (String fail1 : failList) {
            System.out.println(fail1);
        }
    }

    private static void post2() {
        for (int i = 0; i <1660; i=i+20) {
            String url = "http://api.qixin.com/APIService/qc/getANList?" +
                    "name=沧州明珠塑料股份有限公司" +
                    "&appkey=df497b29-1d10-4aac-b922-9fa402750751" +
                    "&secret_key=d10a26d1-34db-4b91-8dd0-2df486a462bc" +
                    "&skip=" + i ;


            System.out.println(url);
            String result = HttpRequest.get(url)/*.addHeaders(header)*/.execute().body();
            System.out.println(result);
        }

    }

    public static void main(String[] args) {
//        post1();
        Long i = Long.MAX_VALUE;
        if (i != 0) {
            System.out.println(1);
        }
    }
}
